package com.yykj.hospital.server.controller;

import com.yykj.common.vo.PageData;
import com.yykj.hospital.client.dto.bank.DoctorBankCashApplyDTO;
import com.yykj.hospital.client.form.bank.CashApplyCheckForm;
import com.yykj.hospital.server.form.bank.DoctorCashApplySearchForm;
import com.yykj.hospital.server.model.entity.bank.DoctorBankCashApply;
import com.yykj.hospital.server.service.bank.BankService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *
 * Created by chendg on 2021/9/8 0008.
 */
@Slf4j
@RestController
@RequestMapping("/api/proto/hospital/doctor/cash")
@Api(tags = "医院后台 -- 提现相关接口")
@SuppressWarnings(value = "unchecked")
public class ProtoDoctorCashController {

	@ApiOperation("提现申请--审核拒绝")
	@PostMapping("/refused")
	public void refuseDoctorCashApply(@RequestBody CashApplyCheckForm form){
		bankService.refuseDoctorCashApply(form.getOrderNo(),form.getRemark());
	}


	@ApiOperation("提现申请 -- 审核通过")
	@PostMapping("/pass")
	public void passDoctorCashApply(@RequestBody CashApplyCheckForm form){
		bankService.passDoctorCashApply(form.getOrderNo(),form.getRemark());
	}
	@ApiOperation("提现申请 -- 列表 ")
	@GetMapping("/list")
	public PageData<DoctorBankCashApplyDTO> listDoctorCashApply(@RequestParam(name = "orderNo",required = false) String orderNo,
																@RequestParam(name = "hospitalId",required = false) Integer hospitalId,
																@RequestParam(name = "doctorId",required = false) String doctorId,
																@RequestParam(name = "doctorName",required = false) String doctorName,
																@RequestParam(name = "bankCardNo",required = false) String bankCardNo,
																@RequestParam(name = "startTime",required = false) String startTime,
																@RequestParam(name = "endTime",required = false) String endTime,
																@RequestParam(name = "status",required = false) Integer status,
																@RequestParam(name = "currentPage",defaultValue = "1") Integer currentPage,
																@RequestParam(name = "pageSize",defaultValue = "10") Integer pageSize ){
		DoctorCashApplySearchForm form = DoctorCashApplySearchForm.builder()
				.orderNo(orderNo)
				.hospitalId(hospitalId)
				.doctorId(doctorId)
				.doctorName(doctorName)
				.bankCardNo(bankCardNo)
				.status(status)
				.startTime(startTime)
				.endTime(endTime)
				.currentPage(currentPage)
				.pageSize(pageSize)
				.build();

		return bankService.listDoctorCashApply(form);
	}

	private BankService bankService;

	@Autowired
	public void setBankService(BankService bankService) {
		this.bankService = bankService;
	}
}
